from django import template
from django.utils.safestring import mark_safe

register = template.Library()  # register的名字是固定的,不可改变

@register.filter
def sub(v1, v2):
    return v1 * v2

# 一个参数的过滤器
@register.filter
def singer_filter(self):
    return self

# 两个参数的过滤器
@register.filter
def double_filter(self, value):
    return self * value

@register.simple_tag
def my_html(v1, v2):
    temp_html = "<input type='text' id='%s' class='%s' />" % (v1, v2)
    return mark_safe(temp_html)

@register.simple_tag
def add(v1, v2, v3):
    return v1 + v2 + v3
